package com.bcxj.servicemap.controller;

import com.bcxj.internalcommon.dto.ForecastPriceDTO;
import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.response.DirectionResponse;
import com.bcxj.servicemap.service.DirectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: DirectionController
 * Package: com.bcxj.servicemap.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/10/5 15:31
 * @Version 1.0
 * @Since 1.0
 */
@RestController
@RequestMapping("/direction")
public class DirectionController {

    @Autowired
    private DirectionService directionService;

    /**
     * 调用第三方API获取 两地的距离和行驶的大致时间
     * @param forecastPriceDTO 经纬度
     * @return
     */
    @GetMapping("/driving")
    public ResponseResult<DirectionResponse> driving(@RequestBody ForecastPriceDTO forecastPriceDTO) {
        String depLongitude = forecastPriceDTO.getDepLongitude();
        String depLatitude = forecastPriceDTO.getDepLatitude();
        String destLongitude = forecastPriceDTO.getDestLongitude();
        String destLatitude = forecastPriceDTO.getDestLatitude();
        return directionService.driving(depLongitude,depLatitude,destLongitude,destLatitude);
    }

}
